<!DOCTYPE html>
<html>
<head lang="en">
    <meta charset="UTF-8">
    <meta name="viewport"
          content="width=device-width, user-scalable=no, initial-scale=1.0,
           maximum-scale=1.0, minimum-scale=1.0"/>
    <title>angular实现点击滚动</title>
    <style>
        #parent div{
            width: 300px;
            height: 500px;
            border: 1px #000 solid;
            margin: 20px;
        }
        #parent ul{
            width: 200px;
            position: fixed;
            top: 0;
            right: 0;
        }
    </style>

    <script src="js/angular.js"></script>
</head>
<body>
    <div ng-app="myApp">
        <div id="parent" ng-controller="fristControl">
            <ul>
                <li ng-repeat="id in [1,2,3,4,5]" ng-click="change('div'+id)">{{id}}aaa</li>
            </ul>
            <div ng-repeat="id in [1,2,3,4,5]" ng-attr-id="div{{id}}">{{id}}</div>
        </div>
    </div>
</body>
<script>
    /*说明
    * ng-attr-id 这个是用与设置id的，可以在遍历中使用
    * $location.hash(id) 用与实现跳转到访问的id定位处
    * */
    var app=angular.module('myApp',[]);
    app.controller("fristControl",['$scope','$location','$anchorScroll',
        function ($scope, $location,$anchorScroll) {
            $scope.change= function (div) {
                //定位到给定id的元素上面
                $location.hash(div);
                alert(div);
            }
    }]);
</script>
</html>